﻿using Moqikaka.BLL;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;

namespace OldPlayersReturn
{
    public class Global : System.Web.HttpApplication
    {

        protected void Application_Start(object sender, EventArgs e)
        {
            BLLExecuteActions.Init();
            Moqikaka.DAL.GameBaseDAL.DBConnectionString =
                System.Configuration.ConfigurationManager.ConnectionStrings["DBConnection"].ConnectionString.ToString();

        }

        protected void Session_Start(object sender, EventArgs e)
        {

        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {

        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {
            Exception ex = Server.GetLastError();
            Server.ClearError();

            var responseContent = JsonConvert.SerializeObject(new ResultResponse()
            {
                ResultCode = ResultCodeEnum.Error
#if DEBUG
,
                 //Message = ex.Message + ex.StackTrace
                Message = ex.Message
#else
                Message = "error！";
#endif
            });
            HttpContext.Current.Response.Write(responseContent);
            HttpContext.Current.Response.End();
        }

        protected void Session_End(object sender, EventArgs e)
        {

        }

        protected void Application_End(object sender, EventArgs e)
        {

        }
    }
}